﻿using System.Configuration;
using System.Text.RegularExpressions;

namespace ECG.WebUI.CustomHelpers
{
    public static class ExtensionMethodHelper
    {
        public static string ImagePathThumb(this string str, int width, int height)
        {
            var hostContainImages = ConfigurationManager.AppSettings["HostContainImages"];
            var imgPath = string.IsNullOrEmpty(str) ? "" : string.Format("{0}{1}?width={2}&height={3}", hostContainImages, str, width, height);
            return imgPath;
        }

        public static string ImagePathThumbDefault(this string str)
        {
            var hostContainImages = ConfigurationManager.AppSettings["HostContainImages"];
            var imgPath = string.IsNullOrEmpty(str) ? "" : string.Format("{0}{1}", hostContainImages, str);
            return imgPath;
        }

        public static string ReplaceSpecialAsEmpty(this string str)
        {
            str = str.Trim().Replace(" ","-");
            var replaced = Regex.Replace(str, @"[^\d\w\s*]", "-");
            return replaced;
        }
    }
}